package net.cyndeline.components.item

import scala.math.{min => lowest, max => highest}
import net.cyndeline.entitySystem.Component

/**
 * Keeps track of the number of experience points an entity has
 * currently accumulated. Also specifies which level the entity is at.
 */
trait ExperienceComponent extends Component {
  
  /** The current level of this entity. */
  def level: Int
  
  /** Sets a new level. */
  def level_=(newLevel: Int)
  
  /** The max amount of experience that can be had. */
  def max: Int
  
  /** Sets a new max experience amount. */
  def max_=(newMax: Int)
  
  /** Returns the current experience amount. */
  def current: Int
  
  /**
   * Modifies the experience amount by some value. The final value cannot
   * go below 0 or above the maximum value.
   * @param amount Amount to modify the experience by. Can be both 
   * 			   negative and positive. 
   */
  def current_=(amount: Int)
}

class Experience extends ExperienceComponent {
  override var level = 0
  override var current = 0
  override var max = 0
  
  override def copy = {
    val copy = new Experience()
    copy.level = level
    copy.max = max
    copy.current = current
    copy
  }
}